//
//  ExtensionViewController.swift
//  test_swift
//
//  Created by fangyuan ding on 2021/6/1.
//

import UIKit
extension Int {
   var add: Int {return self + 100 }
   var sub: Int { return self - 10 }
   var mul: Int { return self * 10 }
   var div: Int { return self / 5 }
}
struct sum {
    var num1 = 100, num2 = 200
}

struct diff {
    var no1 = 200, no2 = 100
}

struct mult {
    var a = sum()
    var b = diff()
}
extension mult {
    init(x: sum, y: diff) {
        _ = x.num1 + x.num2
        _ = y.no1 + y.no2
    }
}
class ExtensionViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
            
        let addition = 3.add
        print("加法运算后的值：\(addition)")
            
        let subtraction = 120.sub
        print("减法运算后的值：\(subtraction)")
            
        let multiplication = 39.mul
        print("乘法运算后的值：\(multiplication)")
            
        let division = 55.div
        print("除法运算后的值: \(division)")

        let mix = 30.add + 34.sub
        print("混合运算结果：\(mix)")
        

        let a = sum(num1: 100, num2: 200)
        let b = diff(no1: 200, no2: 100)

        let getMult = mult(x: a, y: b)
        print("getMult sum\(getMult.a.num1)")
        print("getMult diff\(getMult.b.no1)")
    }
    


}
